<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>赛诺菲_西南区 销量统计系统</title>
<%@ include file="../inc/fileHead.jsp"%>
	<body class="easyui-layout">
	<div data-options="region:'center',border:false" style="height:100%;">
	<div align="center" style="height: 20px;font-size: large">
		<a href="demo.xls">PM文件上传模板下载</a>
	</div>
	<table id="dg" title="流向记录" class="easyui-datagrid"
		 url="PmAction_findAlluploadfile"
		toolbar="#toolbar" pagination="true" rownumbers="true"
		fitColumns="true" singleSelect="true">
		<thead>
			<tr>
				<th field="customerlevel" width="50">客户级别</th>
				<th field="customername" width="50">客户名称</th>
				<th field="actiondate" width="50">流向月份</th>
				<th field="uploadfilename" width="50">流向文件名</th>
				<th field="customerid" width="50" hidden=true>客户ID </th>
			</tr>
		</thead>
	</table>
	<div id="toolbar">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-add" plain="true" onclick="newUser()">添加流向</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-remove" plain="true" onclick="destroyUser()">删除流向</a>
	</div>

	<div id="dlg" class="easyui-dialog"
		style="width: 400px; height: 280px; padding: 10px 20px" closed="true"
		buttons="#dlg-buttons">
		<div class="ftitle">流向信息</div>
		<form id="fm" method="post" novalidate enctype="multipart/form-data">
			<div class="fitem">
				<label> 客户级别 </label> <input required="true" class="easyui-combobox"
					name="customerlevel"
					data-options="  
                    url:'BaseAction_selectGetCustomerLevel',  
                    valueField:'id',  
                    textField:'name',  
                    panelHeight:'auto',
                    onSelect:function(rec){
                    var url = 'BaseAction_selectGetCustomerNameByLevel?customerlevel='+rec.id; 
                     $('#customerid').combobox('reload', url); 
                    }
            " />
			</div>
			<div class="fitem">
				<label> 客户名称 </label> <input id="customerid" required="true"
					class="easyui-combobox" name="customerid"
					data-options="  
                    valueField:'id',  
                    textField:'name',  
                    panelHeight:'auto'  
            " />
			</div>
			<div class="fitem">
				<label> 流向日期 </label> <input id="liquiddate" type="text"
					class="easyui-datebox" name="liquiddate" required="required"></input>
			</div>
			<div class="fitem">
				<label> 流向文件名 </label> <input type="file" name="uploadfile"
					class="easyui-validatebox" required="true">
			</div>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-ok" onclick="saveUser()">保存</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
	</div>
	<script type="text/javascript">
		var url;

		function newUser() {
			$('#dlg').dialog('open').dialog('setTitle', '添加流向');
			$('#query').form('clear');
			url = 'PmAction_uploadfile';
		}
		function saveUser() {
			$('#fm').form('submit', {
				url : url,
				onSubmit : function() {
					return $(this).form('validate');
				},
				success : function(result) {
					var result = eval('(' + result + ')');
					if (result.errorMsg) {
						$.messager.alert('错误',result.errorMsg); 
					} else {
						$.messager.alert('提示','操作成功！'); 
						$('#dlg').dialog('close'); // close the dialog  
						$('#dg').datagrid('reload'); // reload the user data  
					}
				}
			});
		}
		function destroyUser() {
			var row = $('#dg').datagrid('getSelected');
			if (row) {
				$.messager.confirm('Confirm',
						'确定删除该流向?',
						function(r) {
							if (r) {
								$.post('PmAction_deleteFile', {
									id : row.id,
									customerid : row.customerid
								}, function(result) {
									if (result.success) {
										$.messager.alert('提示',"删除成功"); 
										$('#dg').datagrid('reload'); // reload the user data  
									} else {
										$.messager.alert('错误',result.errorMsg); 
									}
								}, 'json');
							}
						});
			}
		}
	</script>
	<script type="text/javascript">
		$(function() {
			$('#cc')
					.combobox(
							{
								formatter : function(row) {
									var imageFile = 'images/' + row.icon;
									return '<img class="item-img" src="'+imageFile+'"/><span class="item-text">'
											+ row.text + '</span>';
								}
							});
		});
	</script>

	<style type="text/css">
#fm {
	margin: 0;
	padding: 10px 30px;
}

.ftitle {
	font-size: 14px;
	font-weight: bold;
	padding: 5px 0;
	margin-bottom: 10px;
	border-bottom: 1px solid #ccc;
}

.fitem {
	margin-bottom: 5px;
}

.fitem label {
	display: inline-block;
	width: 80px;
}
</style>
</div>
</body>
</html>